package com.prs.crm.dao.cdxh.impl;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;

import org.courser.hibernate.QueryExample;
import org.courser.ui.PaginationSupport;
import org.hibernate.Criteria;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;
import org.springframework.orm.hibernate3.HibernateCallback;

import com.prs.crm.dao.cdxh.cd_ProductClassDao;
import com.prs.crm.dao.impl.BaseDaoImpl;
import com.prs.crm.domain.cdxh.HrPerson;
import com.prs.crm.domain.cdxh.cd_ProductClass;
import com.prs.crm.domain.stock.ProductStore;

public class cd_ProductClassDaoImpl extends BaseDaoImpl<cd_ProductClass>
		implements cd_ProductClassDao {

	@SuppressWarnings("unchecked")
	@Override
	public List<cd_ProductClass> getAllCdProductClasses() {
		return (List<cd_ProductClass>) getHibernateTemplate().execute(
				new HibernateCallback() {
					public Object doInHibernate(Session session)
							throws HibernateException {
						Criteria criteria = session
								.createCriteria(cd_ProductClass.class);
						
						return criteria.list();
					}
				});
	}

	@SuppressWarnings({ "unchecked", "rawtypes" })
	@Override
	public cd_ProductClass getcd_ProductClass(final String className) {
		return (cd_ProductClass)this.getHibernateTemplate().execute(
			      new HibernateCallback() {   
						public Object doInHibernate(Session session) throws HibernateException {
				        	Criteria criteria = session.createCriteria(cd_ProductClass.class);
				        	criteria.add(Restrictions.eq("productClassName", className));		        	
				        	List<cd_ProductClass> result = criteria.list();
				        	int zsize=result.size();
				        		if(zsize==0){
				        			return null;
				        		}else{
				        			return result.get(0);
				        		}
				         
				 } });
	}



}
